import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

const store = new Vuex.Store({
    state:{
        user:''
    },
    getters:{//监听值得变化
        getUser:function(state){
            return state.user
        }
    },
    mutations:{
        set(state,user){
            state.user=user;
        },
        get(state){
            state.user=state.user;
        }
    },

    actions:{
        setFun(context,user){
            context.commit("set",user)
        },
        getFun(context){
            context.commit("get")
        }
    }

});

export default store;